/*
 * Copyright (c) 2018 Tencent. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
const AbstractModel = require("../../common/abstract_model");

/**
 * DescribeFabricBlock request structure.
 * @class
 */
class DescribeFabricBlockRequest extends  AbstractModel {
    constructor(){
        super();

        /**
         * Cluster ID, which can be obtained from the blockchain cluster details or in the list.
         * @type {string || null}
         */
        this.ClusterId = null;

        /**
         * Channel ID, which can be obtained from the channel list or channel detail.
         * @type {string || null}
         */
        this.ChannelId = null;

        /**
         * Block height, starting from 0.
         * @type {number || null}
         */
        this.BlockHeight = null;

    }

    /**
     * @private
     */
    deserialize(params) {
        if (!params) {
            return;
        }
        this.ClusterId = 'ClusterId' in params ? params.ClusterId : null;
        this.ChannelId = 'ChannelId' in params ? params.ChannelId : null;
        this.BlockHeight = 'BlockHeight' in params ? params.BlockHeight : null;

    }
}

/**
 * InvokeFabricChaincode response structure.
 * @class
 */
class InvokeFabricChaincodeResponse extends  AbstractModel {
    constructor(){
        super();

        /**
         * Transaction ID
         * @type {string || null}
         */
        this.TxId = null;

        /**
         * Transaction status.
         * @type {string || null}
         */
        this.TxStatus = null;

        /**
         * Transaction result.
         * @type {string || null}
         */
        this.TxResult = null;

        /**
         * The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.
         * @type {string || null}
         */
        this.RequestId = null;

    }

    /**
     * @private
     */
    deserialize(params) {
        if (!params) {
            return;
        }
        this.TxId = 'TxId' in params ? params.TxId : null;
        this.TxStatus = 'TxStatus' in params ? params.TxStatus : null;
        this.TxResult = 'TxResult' in params ? params.TxResult : null;
        this.RequestId = 'RequestId' in params ? params.RequestId : null;

    }
}

/**
 * Transaction overview information display.
 * @class
 */
class Transaction extends  AbstractModel {
    constructor(){
        super();

        /**
         * Transaction ID
         * @type {string || null}
         */
        this.TxId = null;

        /**
         * Contract name.
         * @type {string || null}
         */
        this.ChaincodeName = null;

        /**
         * Transaction sender.
         * @type {string || null}
         */
        this.Sender = null;

        /**
         * Transaction creation time.
         * @type {string || null}
         */
        this.CreateTime = null;

        /**
         * The block height where the trading platform is located.
         * @type {number || null}
         */
        this.BlockHeight = null;

        /**
         * The serial number of a transaction in a block.
         * @type {number || null}
         */
        this.TxIndex = null;

    }

    /**
     * @private
     */
    deserialize(params) {
        if (!params) {
            return;
        }
        this.TxId = 'TxId' in params ? params.TxId : null;
        this.ChaincodeName = 'ChaincodeName' in params ? params.ChaincodeName : null;
        this.Sender = 'Sender' in params ? params.Sender : null;
        this.CreateTime = 'CreateTime' in params ? params.CreateTime : null;
        this.BlockHeight = 'BlockHeight' in params ? params.BlockHeight : null;
        this.TxIndex = 'TxIndex' in params ? params.TxIndex : null;

    }
}

/**
 * InvokeFabricChaincode request structure.
 * @class
 */
class InvokeFabricChaincodeRequest extends  AbstractModel {
    constructor(){
        super();

        /**
         * Cluster ID, which can be obtained from the blockchain cluster details.
         * @type {string || null}
         */
        this.ClusterId = null;

        /**
         * Channel ID, which can be obtained from the channel list or channel detail.
         * @type {string || null}
         */
        this.ChannelId = null;

        /**
         * Contract name. it can be obtained from the contract list or contract details.
         * @type {string || null}
         */
        this.ChaincodeName = null;

        /**
         * Contract method.
         * @type {string || null}
         */
        this.FuncName = null;

        /**
         * Contract method input parameter.
         * @type {Array.<string> || null}
         */
        this.FuncParam = null;

        /**
         * Whether to execute asynchronously. if so, use the transaction TxID in the return value to query the execution result.
         * @type {boolean || null}
         */
        this.WithAsyncResult = null;

    }

    /**
     * @private
     */
    deserialize(params) {
        if (!params) {
            return;
        }
        this.ClusterId = 'ClusterId' in params ? params.ClusterId : null;
        this.ChannelId = 'ChannelId' in params ? params.ChannelId : null;
        this.ChaincodeName = 'ChaincodeName' in params ? params.ChaincodeName : null;
        this.FuncName = 'FuncName' in params ? params.FuncName : null;
        this.FuncParam = 'FuncParam' in params ? params.FuncParam : null;
        this.WithAsyncResult = 'WithAsyncResult' in params ? params.WithAsyncResult : null;

    }
}

/**
 * QueryFabricChaincode request structure.
 * @class
 */
class QueryFabricChaincodeRequest extends  AbstractModel {
    constructor(){
        super();

        /**
         * Cluster ID, which can be obtained from the blockchain cluster details.
         * @type {string || null}
         */
        this.ClusterId = null;

        /**
         * Channel ID, which can be obtained from the channel list or channel details.
         * @type {string || null}
         */
        this.ChannelId = null;

        /**
         * Contract name. it can be obtained from the contract list or contract details.
         * @type {string || null}
         */
        this.ChaincodeName = null;

        /**
         * Contract method.
         * @type {string || null}
         */
        this.FuncName = null;

        /**
         * Contract method input parameter.
         * @type {Array.<string> || null}
         */
        this.FuncParam = null;

    }

    /**
     * @private
     */
    deserialize(params) {
        if (!params) {
            return;
        }
        this.ClusterId = 'ClusterId' in params ? params.ClusterId : null;
        this.ChannelId = 'ChannelId' in params ? params.ChannelId : null;
        this.ChaincodeName = 'ChaincodeName' in params ? params.ChaincodeName : null;
        this.FuncName = 'FuncName' in params ? params.FuncName : null;
        this.FuncParam = 'FuncParam' in params ? params.FuncParam : null;

    }
}

/**
 * DescribeFabricBlock response structure.
 * @class
 */
class DescribeFabricBlockResponse extends  AbstractModel {
    constructor(){
        super();

        /**
         * Block height.
         * @type {number || null}
         */
        this.BlockHeight = null;

        /**
         * Block Hash.
         * @type {string || null}
         */
        this.BlockHash = null;

        /**
         * Pre-Block Hash.
         * @type {string || null}
         */
        this.PreBlockHash = null;

        /**
         * The number of transactions in a block.
         * @type {number || null}
         */
        this.TxCount = null;

        /**
         * Transaction list in the block.
         * @type {Array.<Transaction> || null}
         */
        this.TransactionList = null;

        /**
         * Creation Timestamp
         * @type {string || null}
         */
        this.CreateTimestamp = null;

        /**
         * Proposal organization.
         * @type {string || null}
         */
        this.ProposerOrg = null;

        /**
         * The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.
         * @type {string || null}
         */
        this.RequestId = null;

    }

    /**
     * @private
     */
    deserialize(params) {
        if (!params) {
            return;
        }
        this.BlockHeight = 'BlockHeight' in params ? params.BlockHeight : null;
        this.BlockHash = 'BlockHash' in params ? params.BlockHash : null;
        this.PreBlockHash = 'PreBlockHash' in params ? params.PreBlockHash : null;
        this.TxCount = 'TxCount' in params ? params.TxCount : null;

        if (params.TransactionList) {
            this.TransactionList = new Array();
            for (let z in params.TransactionList) {
                let obj = new Transaction();
                obj.deserialize(params.TransactionList[z]);
                this.TransactionList.push(obj);
            }
        }
        this.CreateTimestamp = 'CreateTimestamp' in params ? params.CreateTimestamp : null;
        this.ProposerOrg = 'ProposerOrg' in params ? params.ProposerOrg : null;
        this.RequestId = 'RequestId' in params ? params.RequestId : null;

    }
}

/**
 * QueryFabricChaincode response structure.
 * @class
 */
class QueryFabricChaincodeResponse extends  AbstractModel {
    constructor(){
        super();

        /**
         * Transaction ID
         * @type {string || null}
         */
        this.TxId = null;

        /**
         * Transaction status.
         * @type {string || null}
         */
        this.TxStatus = null;

        /**
         * Transaction result.
         * @type {string || null}
         */
        this.TxResult = null;

        /**
         * The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.
         * @type {string || null}
         */
        this.RequestId = null;

    }

    /**
     * @private
     */
    deserialize(params) {
        if (!params) {
            return;
        }
        this.TxId = 'TxId' in params ? params.TxId : null;
        this.TxStatus = 'TxStatus' in params ? params.TxStatus : null;
        this.TxResult = 'TxResult' in params ? params.TxResult : null;
        this.RequestId = 'RequestId' in params ? params.RequestId : null;

    }
}

/**
 * DescribeFabricTransaction response structure.
 * @class
 */
class DescribeFabricTransactionResponse extends  AbstractModel {
    constructor(){
        super();

        /**
         * Transaction ID
         * @type {string || null}
         */
        this.TxId = null;

        /**
         * Transaction Hash.
         * @type {string || null}
         */
        this.TxHash = null;

        /**
         * Transaction status.
         * @type {string || null}
         */
        this.TxStatus = null;

        /**
         * Organization list involved.
         * @type {Array.<string> || null}
         */
        this.JoinOrgList = null;

        /**
         * Transaction sender.
         * @type {string || null}
         */
        this.Sender = null;

        /**
         * Creation time
         * @type {string || null}
         */
        this.CreateTime = null;

        /**
         * Block height.
         * @type {number || null}
         */
        this.BlockHeight = null;

        /**
         * The contract to which the exchange belongs.
         * @type {string || null}
         */
        this.ChaincodeName = null;

        /**
         * Transaction data, base64 encoded, decoded as a json string.
         * @type {string || null}
         */
        this.TransactionData = null;

        /**
         * The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.
         * @type {string || null}
         */
        this.RequestId = null;

    }

    /**
     * @private
     */
    deserialize(params) {
        if (!params) {
            return;
        }
        this.TxId = 'TxId' in params ? params.TxId : null;
        this.TxHash = 'TxHash' in params ? params.TxHash : null;
        this.TxStatus = 'TxStatus' in params ? params.TxStatus : null;
        this.JoinOrgList = 'JoinOrgList' in params ? params.JoinOrgList : null;
        this.Sender = 'Sender' in params ? params.Sender : null;
        this.CreateTime = 'CreateTime' in params ? params.CreateTime : null;
        this.BlockHeight = 'BlockHeight' in params ? params.BlockHeight : null;
        this.ChaincodeName = 'ChaincodeName' in params ? params.ChaincodeName : null;
        this.TransactionData = 'TransactionData' in params ? params.TransactionData : null;
        this.RequestId = 'RequestId' in params ? params.RequestId : null;

    }
}

/**
 * DescribeFabricTransaction request structure.
 * @class
 */
class DescribeFabricTransactionRequest extends  AbstractModel {
    constructor(){
        super();

        /**
         * Cluster ID, which can be obtained from the blockchain cluster details or in the list.
         * @type {string || null}
         */
        this.ClusterId = null;

        /**
         * Channel ID, which can be obtained from the channel list or channel detail.
         * @type {string || null}
         */
        this.ChannelId = null;

        /**
         * Transaction ID
         * @type {string || null}
         */
        this.TxId = null;

    }

    /**
     * @private
     */
    deserialize(params) {
        if (!params) {
            return;
        }
        this.ClusterId = 'ClusterId' in params ? params.ClusterId : null;
        this.ChannelId = 'ChannelId' in params ? params.ChannelId : null;
        this.TxId = 'TxId' in params ? params.TxId : null;

    }
}

module.exports = {
    DescribeFabricBlockRequest: DescribeFabricBlockRequest,
    InvokeFabricChaincodeResponse: InvokeFabricChaincodeResponse,
    Transaction: Transaction,
    InvokeFabricChaincodeRequest: InvokeFabricChaincodeRequest,
    QueryFabricChaincodeRequest: QueryFabricChaincodeRequest,
    DescribeFabricBlockResponse: DescribeFabricBlockResponse,
    QueryFabricChaincodeResponse: QueryFabricChaincodeResponse,
    DescribeFabricTransactionResponse: DescribeFabricTransactionResponse,
    DescribeFabricTransactionRequest: DescribeFabricTransactionRequest,

}
